home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / flight-of-the-museum.swf / scripts / com / google / analytics / core / TrackerCache.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  9.6 KB  |  351 lines

  1. package com.google.analytics.core
  2. {
  3.    import com.google.analytics.v4.GoogleAnalyticsAPI;
  4.    import flash.errors.IllegalOperationError;
  5.    
  6.    public class TrackerCache implements GoogleAnalyticsAPI
  7.    {
  8.       
  9.       public static var CACHE_THROW_ERROR:Boolean;
  10.        
  11.       
  12.       public var tracker:GoogleAnalyticsAPI;
  13.       
  14.       private var _ar:Array;
  15.       
  16.       public function TrackerCache(tracker:GoogleAnalyticsAPI = null)
  17.       {
  18.          super();
  19.          this.tracker = tracker;
  20.          _ar = [];
  21.       }
  22.       
  23.       public function size() : uint
  24.       {
  25.          return _ar.length;
  26.       }
  27.       
  28.       public function flush() : void
  29.       {
  30.          var o:Object = null;
  31.          var name:String = null;
  32.          var args:Array = null;
  33.          var l:int = 0;
  34.          var i:int = 0;
  35.          if(tracker == null)
  36.          {
  37.             return;
  38.          }
  39.          if(size() > 0)
  40.          {
  41.             for(l = int(_ar.length); i < l; )
  42.             {
  43.                o = _ar.shift();
  44.                name = o.name as String;
  45.                args = o.args as Array;
  46.                if(name != null && name in tracker)
  47.                {
  48.                   (tracker[name] as Function).apply(tracker,args);
  49.                }
  50.                i++;
  51.             }
  52.          }
  53.       }
  54.       
  55.       public function enqueue(name:String, ... args) : Boolean
  56.       {
  57.          if(name == null)
  58.          {
  59.             return false;
  60.          }
  61.          _ar.push({
  62.             "name":name,
  63.             "args":args
  64.          });
  65.          return true;
  66.       }
  67.       
  68.       public function link(targetUrl:String, useHash:Boolean = false) : void
  69.       {
  70.          enqueue("link",targetUrl,useHash);
  71.       }
  72.       
  73.       public function addOrganic(newOrganicEngine:String, newOrganicKeyword:String) : void
  74.       {
  75.          enqueue("addOrganic",newOrganicEngine,newOrganicKeyword);
  76.       }
  77.       
  78.       public function setAllowLinker(enable:Boolean) : void
  79.       {
  80.          enqueue("setAllowLinker",enable);
  81.       }
  82.       
  83.       public function trackEvent(category:String, action:String, label:String = null, value:Number = NaN) : Boolean
  84.       {
  85.          enqueue("trackEvent",category,action,label,value);
  86.          return true;
  87.       }
  88.       
  89.       public function getClientInfo() : Boolean
  90.       {
  91.          if(CACHE_THROW_ERROR)
  92.          {
  93.             throw new IllegalOperationError("The tracker is not ready and you can use the \'getClientInfo\' method for the moment.");
  94.          }
  95.          return false;
  96.       }
  97.       
  98.       public function trackTrans() : void
  99.       {
  100.          enqueue("trackTrans");
  101.       }
  102.       
  103.       public function trackPageview(pageURL:String = "") : void
  104.       {
  105.          enqueue("trackPageview",pageURL);
  106.       }
  107.       
  108.       public function setClientInfo(enable:Boolean) : void
  109.       {
  110.          enqueue("setClientInfo",enable);
  111.       }
  112.       
  113.       public function linkByPost(formObject:Object, useHash:Boolean = false) : void
  114.       {
  115.          enqueue("linkByPost",formObject,useHash);
  116.       }
  117.       
  118.       public function setCookieTimeout(newDefaultTimeout:int) : void
  119.       {
  120.          enqueue("setCookieTimeout",newDefaultTimeout);
  121.       }
  122.       
  123.       public function isEmpty() : Boolean
  124.       {
  125.          return _ar.length == 0;
  126.       }
  127.       
  128.       public function getDetectTitle() : Boolean
  129.       {
  130.          if(CACHE_THROW_ERROR)
  131.          {
  132.             throw new IllegalOperationError("The tracker is not ready and you can use the \'getDetectTitle\' method for the moment.");
  133.          }
  134.          return false;
  135.       }
  136.       
  137.       public function resetSession() : void
  138.       {
  139.          enqueue("resetSession");
  140.       }
  141.       
  142.       public function setDetectFlash(enable:Boolean) : void
  143.       {
  144.          enqueue("setDetectFlash",enable);
  145.       }
  146.       
  147.       public function clear() : void
  148.       {
  149.          _ar = [];
  150.       }
  151.       
  152.       public function setCampNameKey(newCampNameKey:String) : void
  153.       {
  154.          enqueue("setCampNameKey",newCampNameKey);
  155.       }
  156.       
  157.       public function addItem(item:String, sku:String, name:String, category:String, price:Number, quantity:int) : void
  158.       {
  159.          enqueue("addItem",item,sku,name,category,price,quantity);
  160.       }
  161.       
  162.       public function createEventTracker(objName:String) : EventTracker
  163.       {
  164.          if(CACHE_THROW_ERROR)
  165.          {
  166.             throw new IllegalOperationError("The tracker is not ready and you can use the \'createEventTracker\' method for the moment.");
  167.          }
  168.          return null;
  169.       }
  170.       
  171.       public function setVar(newVal:String) : void
  172.       {
  173.          enqueue("setVar",newVal);
  174.       }
  175.       
  176.       public function clearIgnoredOrganic() : void
  177.       {
  178.          enqueue("clearIgnoredOrganic");
  179.       }
  180.       
  181.       public function setDomainName(newDomainName:String) : void
  182.       {
  183.          enqueue("setDomainName",newDomainName);
  184.       }
  185.       
  186.       public function setCampSourceKey(newCampSrcKey:String) : void
  187.       {
  188.          enqueue("setCampSourceKey",newCampSrcKey);
  189.       }
  190.       
  191.       public function addTrans(orderId:String, affiliation:String, total:Number, tax:Number, shipping:Number, city:String, state:String, country:String) : Object
  192.       {
  193.          if(CACHE_THROW_ERROR)
  194.          {
  195.             throw new IllegalOperationError("The tracker is not ready and you can use the \'addTrans\' method for the moment.");
  196.          }
  197.          return null;
  198.       }
  199.       
  200.       public function setCampContentKey(newCampContentKey:String) : void
  201.       {
  202.          enqueue("setCampContentKey",newCampContentKey);
  203.       }
  204.       
  205.       public function setLocalServerMode() : void
  206.       {
  207.          enqueue("setLocalServerMode");
  208.       }
  209.       
  210.       public function getLocalGifPath() : String
  211.       {
  212.          if(CACHE_THROW_ERROR)
  213.          {
  214.             throw new IllegalOperationError("The tracker is not ready and you can use the \'getLocalGifPath\' method for the moment.");
  215.          }
  216.          return "";
  217.       }
  218.       
  219.       public function setAllowAnchor(enable:Boolean) : void
  220.       {
  221.          enqueue("setAllowAnchor",enable);
  222.       }
  223.       
  224.       public function clearIgnoredRef() : void
  225.       {
  226.          enqueue("clearIgnoredRef");
  227.       }
  228.       
  229.       public function setLocalGifPath(newLocalGifPath:String) : void
  230.       {
  231.          enqueue("setLocalGifPath",newLocalGifPath);
  232.       }
  233.       
  234.       public function getVersion() : String
  235.       {
  236.          if(CACHE_THROW_ERROR)
  237.          {
  238.             throw new IllegalOperationError("The tracker is not ready and you can use the \'getVersion\' method for the moment.");
  239.          }
  240.          return "";
  241.       }
  242.       
  243.       public function setCookiePath(newCookiePath:String) : void
  244.       {
  245.          enqueue("setCookiePath",newCookiePath);
  246.       }
  247.       
  248.       public function setSampleRate(newRate:Number) : void
  249.       {
  250.          enqueue("setSampleRate",newRate);
  251.       }
  252.       
  253.       public function setDetectTitle(enable:Boolean) : void
  254.       {
  255.          enqueue("setDetectTitle",enable);
  256.       }
  257.       
  258.       public function setAllowHash(enable:Boolean) : void
  259.       {
  260.          enqueue("setAllowHash",enable);
  261.       }
  262.       
  263.       public function addIgnoredOrganic(newIgnoredOrganicKeyword:String) : void
  264.       {
  265.          enqueue("addIgnoredOrganic",newIgnoredOrganicKeyword);
  266.       }
  267.       
  268.       public function setCampNOKey(newCampNOKey:String) : void
  269.       {
  270.          enqueue("setCampNOKey",newCampNOKey);
  271.       }
  272.       
  273.       public function getServiceMode() : ServerOperationMode
  274.       {
  275.          if(CACHE_THROW_ERROR)
  276.          {
  277.             throw new IllegalOperationError("The tracker is not ready and you can use the \'getServiceMode\' method for the moment.");
  278.          }
  279.          return null;
  280.       }
  281.       
  282.       public function setLocalRemoteServerMode() : void
  283.       {
  284.          enqueue("setLocalRemoteServerMode");
  285.       }
  286.       
  287.       public function cookiePathCopy(newPath:String) : void
  288.       {
  289.          enqueue("cookiePathCopy",newPath);
  290.       }
  291.       
  292.       public function getDetectFlash() : Boolean
  293.       {
  294.          if(CACHE_THROW_ERROR)
  295.          {
  296.             throw new IllegalOperationError("The tracker is not ready and you can use the \'getDetectFlash\' method for the moment.");
  297.          }
  298.          return false;
  299.       }
  300.       
  301.       public function setCampaignTrack(enable:Boolean) : void
  302.       {
  303.          enqueue("setCampaignTrack",enable);
  304.       }
  305.       
  306.       public function clearOrganic() : void
  307.       {
  308.          enqueue("clearOrganic");
  309.       }
  310.       
  311.       public function setCampTermKey(newCampTermKey:String) : void
  312.       {
  313.          enqueue("setCampTermKey",newCampTermKey);
  314.       }
  315.       
  316.       public function addIgnoredRef(newIgnoredReferrer:String) : void
  317.       {
  318.          enqueue("addIgnoredRef",newIgnoredReferrer);
  319.       }
  320.       
  321.       public function setCampMediumKey(newCampMedKey:String) : void
  322.       {
  323.          enqueue("setCampMediumKey",newCampMedKey);
  324.       }
  325.       
  326.       public function setSessionTimeout(newTimeout:int) : void
  327.       {
  328.          enqueue("setSessionTimeout",newTimeout);
  329.       }
  330.       
  331.       public function setRemoteServerMode() : void
  332.       {
  333.          enqueue("setRemoteServerMode");
  334.       }
  335.       
  336.       public function element() : *
  337.       {
  338.          return _ar[0];
  339.       }
  340.       
  341.       public function getAccount() : String
  342.       {
  343.          if(CACHE_THROW_ERROR)
  344.          {
  345.             throw new IllegalOperationError("The tracker is not ready and you can use the \'getAccount\' method for the moment.");
  346.          }
  347.          return "";
  348.       }
  349.    }
  350. }
  351.